package com.zhangjianling.premp.entity.sys;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.*;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * 部门管理
 * 
 * @author zhangjl
 *
 */
@Entity
@Table(name = "sys_menu")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysMenu implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid.hex")
	@Column(name = "menuid", nullable = false)
	private String menuId;

	private String name;

	@ManyToOne(cascade = {CascadeType.REFRESH},fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	private SysMenu parentMenu;

	@OneToMany(targetEntity = SysMenu.class, cascade = { CascadeType.PERSIST,CascadeType.REFRESH,CascadeType.REMOVE}, fetch = FetchType.LAZY, mappedBy = "parentMenu")
	@JsonIgnore
	private List<SysMenu> childMenu = new ArrayList<SysMenu>();

	@Column(name = "type")
	private String type;//角色类型：【菜单：1|按钮：0】

	@Column(name = "permission")
	private String permission;//权限字符串

	@Column(name = "url")
	private String url;//url路径

	@Column(name = "priority")
	private String priority;//显示顺序

	@Column(name = "status")
	private String status;

	@Column(name = "createtime",updatable=false)
	private String createTime;

	@Column(name = "updatetime")
	private String updateTime;

	@Column(name = "createuser",updatable=false)
	private String createUser;

	@Column(name = "updateuser")
	private String updateUser;

	@Column(name = "remark")
	private String remark;

	@Transient
	private String pName;

	@Column(name="icon",length=40)
	private String icon;//图标样式

	@Column(name="is_iframe",length=2)
	private String isIframe;//是否嵌入新页面

	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="order_role",length=4)
	private int orderRole;//排序规则

	@Column(name="is_open",length=1)
	private String isOpen;//是否打开一个新页面

	@Column(name="is_main",length=1)
	private String isMain;//是否是主页
}
